<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body style="min-width: 30px;">

  <div class="col-xs-12 col-sm-12 col-md-6 col-md-offset-3 col-lg-6 col-lg-offset-3" style="border: 1px solid #ccc">

    <div class="modal-header">
      <h4 class="modal-title">评估问卷</h4>
    </div>
    <c:choose>
      <c:when test="${noData}">
        <div class="modal-body">
          ${message}
          <div class="modal-footer ms-modal-footer">

            <button type="button" onclick="guanbi()" class="btn btn-shadow-default btn-shadow umu-btn" data-dismiss="modal">取消</button>
          </div>
        </div>
      </c:when>
      <c:otherwise>

        <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/survey" data-validate="true">

          <input type="hidden" name="projectPhaseId" value="${projectPhase.id}" /> <input type="hidden" name="traineeId" value="${trainee.id}" />

          <div class="modal-body">
            <p>[${trainee.name}]：</p>
            您好，为了帮助主办方和讲师改进和提升，旭辉学院邀请您对本次学习项目进行评价，本次为匿名评价，填写邮箱仅为防止重复提交，请您务必填写真实有效的评价内容。<br />
            <br />

            <c:forEach items="${projectPhaseCourses }" var="projectPhaseCourse" varStatus="pStatus">
              <c:forEach items="${courseSurveys }" var="courseSurvey" varStatus="cStatus">
                <c:if test="${(courseSurvey.category eq projectPhaseCourse.course.type) || (empty  courseSurvey.category  && empty projectPhaseCourse.course.type)  }">
                  <div class="row" style="margin-top: 10px;">
                    <c:choose>
                      <c:when test="${courseSurvey.type eq 'title' }">
                        <label class="col-xs-12 col-sm-12 col-lg-6 col-md-6 h5"><Strong>${fn:replace(fn:replace(courseSurvey.question,"course_name",projectPhaseCourse.course.name) ,"trainer_name",projectPhaseCourse.trainer.name) }</Strong></label>
                      </c:when>
                      <c:otherwise>
                        <label class="col-xs-12 col-sm-12 col-lg-6 col-md-6 h5">${fn:replace(fn:replace(courseSurvey.question,"course_name",projectPhaseCourse.course.name) ,"trainer_name",projectPhaseCourse.trainer.name) }</label>
                      </c:otherwise>
                    </c:choose>
                    <div class="col-xs-12 col-sm-12 col-lg-6 col-md-6">
                      <c:choose>
                        <c:when test="${courseSurvey.type eq 'select' }">
                          <c:set var="options" value="${fn:split(courseSurvey.options, ',')}" />
                          <select class="select2 form-control" name="surveyItem" data-validate="required">
                            <option></option>
                            <c:forEach items="${options}" var="option">
                              <c:set var="nv" value="${fn:split(option, '=')}" />
                              <option value="${nv[0]}">${nv[1]}</option>
                            </c:forEach>
                          </select>
                        </c:when>
                        <c:when test="${courseSurvey.type eq 'text' }">
                          <textarea class="form-control" name="surveyItem" value="" placeholder="" autocomplete="off"></textarea>
                        </c:when>
                        <c:when test="${courseSurvey.type eq 'title' }">
                          <textarea class="form-control" style="display: none;" name="surveyItem" value="" placeholder="" autocomplete="off"></textarea>
                        </c:when>
                        <c:otherwise>
                          <input type="text" class="form-control" name="surveyItem" value="" placeholder="" <c:choose><c:when test="${courseSurvey.type eq 'int' }">data-validate="required|number"</c:when><c:otherwise>data-validate="required"</c:otherwise></c:choose> autocomplete="off" />
                        </c:otherwise>
                      </c:choose>
                    </div>
                  </div>
                </c:if>
              </c:forEach>
            </c:forEach>

            <br>
            <c:forEach items="${projectPhaseSurveys }" var="projectPhaseSurvey" varStatus="ppStatus">
              <div class="row" style="margin-top: 10px;">
                <label class="col-xs-12 col-sm-12 col-md-6 col-lg-6 h5">${fn:replace(fn:replace(projectPhaseSurvey.question,"project_name",projectPhase.project.name) ,"phase",projectPhase.phase) }</label>
                <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
                  <c:choose>
                    <c:when test="${projectPhaseSurvey.type eq 'select' }">
                      <c:set var="options" value="${fn:split(projectPhaseSurvey.options, ',')}" />
                      <select class="select2 form-control" name="surveyItem" data-validate="required">
                        <option></option>
                        <c:forEach items="${options}" var="option">
                          <c:set var="nv" value="${fn:split(option, '=')}" />
                          <option value="${nv[0]}">${nv[1]}</option>
                        </c:forEach>
                      </select>
                    </c:when>
                    <c:when test="${projectPhaseSurvey.type eq 'text' }">
                      <textarea class="form-control" name="surveyItem" value="" placeholder="" autocomplete="off"></textarea>
                    </c:when>
                    <c:otherwise>
                      <input type="text" class="form-control" name="surveyItem" value="" placeholder="" <c:choose><c:when test="${courseSurvey.type eq 'int' }">data-validate="required|number"</c:when><c:otherwise>data-validate="required"</c:otherwise></c:choose> autocomplete="off" />
                    </c:otherwise>
                  </c:choose>
                </div>
              </div>
            </c:forEach>

            <div class="modal-footer">
              <a href="javascript:void(0);" type="submit" class="btn btn-shadow-success btn-shadow umu-btn">提交问卷</a>
              <!-- <button type="button" class="btn btn-shadow-default btn-shadow umu-btn" data-dismiss="modal">取消</button> -->
            </div>
          </div>
        </form>
      </c:otherwise>
    </c:choose>

  </div>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/project/public-survey.js" />
  <script type="text/javascript">
      require(['page/project/public-survey'], function(page) {
        page.init();
      })
    </script>
</body>
</html>